Page({
    data: {
        varieties: '', //供应品种
        varietiesShow: false, //供应品种上拉选择框
        columns: ['花艺资材', '绿植盆栽', '永生干花', '保险产品', '鲜花饮食', '鲜花叶材'], //供应品种选项内容
        hasBase: '', //是否有基地
        fileList_top: [], //身份证正面图片数组
        fileList_bottom: [], //身份证反面图片数组
        business_license: [], //营业执照图片数组
        agree: ''
    },
    onChange(event) {
        this.setData({
            hasBase: event.detail,
        });
    },
    showVarieties() {
        this.setData({ varietiesShow: true })
    },
    //品种供应上拉选择框关闭事件
    onClose() {
        this.setData({ varietiesShow: false })
    },
    onCancel() {
        this.setData({ varietiesShow: false })
    },
    //分站选择上拉框选项选中事件
    onConfirm(event) {
        const { picker, value, index } = event.detail;
        this.setData({ varieties: value, varietiesShow: false })
    },
    afterRead_top(event) {
        const { file } = event.detail;
        let { fileList = [] } = this.data;
        file.forEach(item => {
            fileList.push(item);
        })
        this.setData({ fileList_top: fileList });
        // 当设置 mutiple 为 true 时, file 为数组格式，否则为对象格式
        // wx.uploadFile({
        //     url: 'https://example.weixin.qq.com/upload',
        //     filePath: file.url,
        //     name: 'file',
        //     formData: { user: 'test' },
        //     success(res) {
        //         // 上传完成需要更新 fileList
        //         const { fileList = [] } = this.data;
        //         fileList.push({ ...file, url: res.data });
        //         this.setData({ fileList });
        //     },
        // });
    },
    delete_image_top() {
        this.setData({ fileList_top: [] });
    },
    afterRead_bottom(event) {
        const { file } = event.detail;
        let { fileList = [] } = this.data;
        file.forEach(item => {
            fileList.push(item);
        })
        this.setData({ fileList_top: fileList });
        // 当设置 mutiple 为 true 时, file 为数组格式，否则为对象格式
        // wx.uploadFile({
        //     url: 'https://example.weixin.qq.com/upload',
        //     filePath: file.url,
        //     name: 'file',
        //     formData: { user: 'test' },
        //     success(res) {
        //         // 上传完成需要更新 fileList
        //         const { fileList = [] } = this.data;
        //         fileList.push({ ...file, url: res.data });
        //         this.setData({ fileList });
        //     },
        // });
    },
    delete_image_bottom() {
        this.setData({ fileList_top: [] });
    },
    afterRead_business(event) {
        const { file } = event.detail;
        let { fileList = [] } = this.data;
        file.forEach(item => {
            fileList.push(item);
        })
        this.setData({ business_license: fileList });
        // 当设置 mutiple 为 true 时, file 为数组格式，否则为对象格式
        // wx.uploadFile({
        //     url: 'https://example.weixin.qq.com/upload',
        //     filePath: file.url,
        //     name: 'file',
        //     formData: { user: 'test' },
        //     success(res) {
        //         // 上传完成需要更新 fileList
        //         const { fileList = [] } = this.data;
        //         fileList.push({ ...file, url: res.data });
        //         this.setData({ fileList });
        //     },
        // });
    },
    delete_image_business() {
        this.setData({ business_license: [] });
    },
    agree(event) {
        this.setData({ agree: event.detail });
    },
    onLoad: function(options) {

    }
})